<?php
namespace Common\Model;
use Think\Model;
class FinanceModel extends Model {
    /**
     * model的中文名称
     */
    public $modelName = '财务';

    /**
     * model的icon
     */
    public $modelIcon = 'icon-exchange';
    
    protected $_auto = [
        ["create_time", "time", 1, "function"],
        ["update_time", "time", 2, "function"],
    ];
    protected $_validate = [
        ["id", "require", "ID必须填写!"],
        ["user_id", "require", "用户必须填写!"],
        ["pay_type", "require", "支付方式必须填写!"],
        ["amount", "require", "金额必须填写!"],
        ["remark", "require", "备注必须填写!"],
        ["order_type", "require", "订单类型必须填写!"],
        ["order_id", "require", "订单ID必须填写!"],
        ["create_time", "require", "创建时间必须填写!"],
        ["update_time", "require", "更新时间必须填写!"],
    ];
    public $excel = false;
    public $update = false;
    public $fieldMap = [
        "id"=>[
            "type"=>"input",
            "name"=>"ID",
            "list"=>true,
            "search"=>true,
            "input"=>false,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
        "user_id"=>[
            "type"=>"foreign",
            "name"=>"用户",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"user,id,name,input",
            "list_specify"=>"",
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
        "pay_type"=>[
            "type"=>"input",
            "name"=>"支付方式",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
        "amount"=>[
            "type"=>"input",
            "name"=>"金额",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>'
                <php>
                $orderType = preg_replace_callback("/[A-Z]/", function($ma){return "_".strtolower($ma[0]);}, $vo["order_type"]);
                $orderType = trim($orderType, "_");
                $joinNum = D("TouristOrder")->where(["order_type"=>$orderType, "order_id"=>$vo["order_id"]])->count();
                </php>
                <td class="center">{$vo["amount"]}*{$joinNum}</td>
                ',
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
        "remark"=>[
            "type"=>"input",
            "name"=>"备注",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
        "order_type"=>[
            "type"=>"input",
            "name"=>"订单类型",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
        "order_id"=>[
            "type"=>"input",
            "name"=>"订单ID",
            "list"=>true,
            "search"=>false,
            "input"=>true,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
        "create_time"=>[
            "type"=>"input",
            "name"=>"创建时间",
            "list"=>false,
            "search"=>false,
            "input"=>false,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
        "update_time"=>[
            "type"=>"input",
            "name"=>"更新时间",
            "list"=>false,
            "search"=>false,
            "input"=>false,
            "required"=>true,
            "detail"=>true,
            "excel"=>true,
            "content"=>"",
            "list_specify"=>"",
            "update_specify"=>"",
            "detail_specify"=>"",
        ],
    ];
}